package com.mycat.chat.two.msg;

import com.google.gson.Gson;
import com.mycat.chat.two.msg.base.MessageType;

import java.util.Map;

/**
 * ${DESCRIPTION}
 *
 * @author roger.
 * @email 190642964@qq.com
 * @create 2017-02-24
 */
public class Main {

    public static void main(String[] args){

        MessageLogin login = new MessageLogin(MessageType.LOGIN_MSG.getType(),"190642964","123456");

        Gson gson = new Gson();
        String loginMsg = gson.toJson(login);
        System.out.println(loginMsg);

        MessageRegister register = new MessageRegister(MessageType.REGISTER_MSG.getType());
        register.setUserCode("190642964");
        register.setPassword("123456");
        register.setNickName("左佐");
        register.setSignature("左佐的签名");

        String registerMsg = gson.toJson(register);
        System.out.println(registerMsg);

        Map<String,String> map = gson.fromJson(registerMsg, Map.class);
        System.out.println(map.get("messageType"));


    }

}
